<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>页面计数器</title>
</head>
<body>
当前页面已经被访问了<span id="pageCount">0</span>次

<button id="btnClear">clear</button>
</body>
<script>

    /**
     *  Q:如何记录某个用户访问多少页面
     * */
   var pageCount= localStorage.getItem("pageCount");


   if(!pageCount){
       pageCount=1;
   }else {
       pageCount =  parseInt(pageCount)+1;
   }


   document.getElementById('pageCount').innerText = pageCount;
   localStorage.setItem("pageCount",pageCount);

   document.getElementById('btnClear').onclick=function () {
       localStorage.clear();
       document.getElementById('pageCount').innerText =0;
   }

</script>

</html>